package org.example.proxy.dynamic.bytebuddy;

import org.example.proxy.vo.Cat;
import org.example.proxy.vo.Doctor;
import org.example.proxy.vo.Dog;
import org.example.proxy.vo.Student;

/**
 * @author Administrator
 */
public class DynamicByteBuddyProxyTestMain {

    public static void main(String[] args) throws Exception {
        ByteBuddyProxy proxy = new ByteBuddyProxy(new Student("王同学"));
        Student student = (Student) proxy.getProxy();
//        Object result = Student.class.getMethod("wakeup", null).invoke(student, null);
//        System.out.println("最后结果" + result);
        student.wakeup();
        student.sleep();
//
        proxy = new ByteBuddyProxy(new Doctor("张医生"));
        Doctor doctor = (Doctor) proxy.getProxy();
        doctor.wakeup();
        doctor.sleep();
//
        proxy = new ByteBuddyProxy(new Dog("小黑狗"));
        Dog dog = (Dog) proxy.getProxy();
        dog.wakeup();
        dog.sleep();

        proxy = new ByteBuddyProxy(new Cat("小猫咪"));
        Cat cat = (Cat) proxy.getProxy();
        cat.wakeup();
        cat.sleep();
    }
}
